package com.lepu.pcecg500;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.lepu.pcecg500.http.EcgHttpBean;
import com.lepu.pcecg500.http.HttpDataBean;
import com.lepu.pcecg500.http.HttpResultBean;
import com.lepu.pcecg500.http.HttpUrl;
import com.lepu.pcecg500.http.UserInfoBean;
import com.lepu.pcecg500.util.EcgTable;
import com.lepu.pcecg500.util.FileUtils;
import com.lepu.pcecg500.util.FinalDbManager;
import com.lepu.pcecg500.util.GwtjDbUtil;
import com.lepu.pcecg500.util.ImageTool;
import com.permissionx.guolindev.PermissionX;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import rxhttp.RxHttp;

public class SettingActivity extends AppCompatActivity {

    private ImageView iv_back;
    private EditText et_ip_port;
    private Button bt_save;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);

        iv_back = findViewById(R.id.iv_back);
        et_ip_port = findViewById(R.id.et_ip_port);
        bt_save = findViewById(R.id.bt_save);

        String baseurl = SPUtils.getInstance().getString("ipAddress", HttpUrl.baseUrl);
        et_ip_port.setText(baseurl);

        iv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        bt_save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                submitDatas();
            }
        });
    }

    private void submitDatas(){
        String ipPort = et_ip_port.getText().toString().trim();

        if (TextUtils.isEmpty(ipPort)) {
            ToastUtils.showShort("请输入接口地址！");
            return;
        }
        SPUtils.getInstance().put("ipAddress", ipPort);
        ToastUtils.showShort("保存成功！");
    }

}